package com.aliengen.thingple.thingple.maintenance;

import android.app.DialogFragment;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.aliengen.thingple.thingple.DialogRFIDReadingFragment;
import com.aliengen.thingple.thingple.R;
import com.aliengen.thingple.thingple.tag.CylinderTag;
import com.aliengen.thingple.thingple.tag.Tag;
import com.aliengen.thingple.thingple.tag.exception.InvalidTagException;

/**
 * This class is part of the Thingple mobile application for the CMC168 Handheld reader.
 *
 * Copyright AlienGen Limited 2016. All rights reserved.
 *
 * @author Timothé Mermet-Buffet <tim@aliengen.com>
 */
public class MaintenanceActivity extends AppCompatActivity implements DialogRFIDReadingFragment.ReadingDialogListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maintenance);
    }

    public void onClickReadCylinder(View view){
        DialogFragment dialog = new DialogRFIDReadingFragment();
        dialog.show(getFragmentManager(), "MaintenanceReading");
    }

    public Tag getTagFromBytes(byte[] tag) throws InvalidTagException
    {
        return new CylinderTag(tag);
    }

    public void onReadingNew(Tag tag) {
        Intent nextScreen = new Intent(getApplicationContext(), CylinderMaintenanceActivity.class);

        startActivity(nextScreen);

        this.finish();
    }
}
